﻿/**
* jQuery EasyUI 1.4.3
* Copyright (c) 2009-2015 www.jeasyui.com. All rights reserved.
*
* Licensed under the GPL license: http://www.gnu.org/licenses/gpl.txt
* To use it on other terms please contact us at info@jeasyui.com
* http://www.jeasyui.com/license_commercial.php
*
* jQuery EasyUI window 扩展
* jeasyui.extensions.iframe.deal.js
* 开发 流云
* 由 落阳 整理
* 最近更新：2015-12-02
*
* 依赖项：
*   1、jquery.jdirk.js
*
* Copyright (c) 2015 ChenJianwei personal All rights reserved.
*/
(function ($) {

    $.util.namespace("$.fn.panel.extensions");
    $.util.namespace("$.fn.window.extensions");
    $.util.namespace("$.fn.dialog.extensions");


    $.extend($.fn.panel.extensions, {
        onBeforeDestroy: $.fn.panel.defaults.onBeforeDestroy
    });

    $.extend($.fn.window.extensions, {
        onBeforeDestroy: $.fn.window.defaults.onBeforeDestroy
    });

    $.extend($.fn.dialog.extensions, {
        onBeforeDestroy: $.fn.dialog.defaults.onBeforeDestroy
    });


    function onBeforeDestroy() {
        $("iframe,frame", this).each(function () {
            try {
                if (this.contentWindow && this.contentWindow.document && this.contentWindow.close) {
                    this.contentWindow.document.write("");
                    this.contentWindow.close();
                }
                if (window.CollectGarbage) {
                    //console.log("回收iframe");
                    window.CollectGarbage();
                }
            } catch (ex) { }
        }).remove();
    }

    $.fn.panel.defaults.onBeforeDestroy = onBeforeDestroy;
    $.fn.window.defaults.onBeforeDestroy = onBeforeDestroy;
    $.fn.dialog.defaults.onBeforeDestroy = onBeforeDestroy;

})(jQuery);